package util.menu.popumenu.view
{
	import core.manager.MainSystem;
	
	import flash.events.MouseEvent;
	
	public class PopupMenuManager
	{
		private var popupMenuList:Object=new Object();
		private var id:int=-1;
		private var obj:*;
		private var popupMenu:PopupMenu;
		public function init(obj:*,name:String,id:int):void
		{
			this.id=id;
			this.obj=obj;
			obj["id"]=id;
			obj.addEventListener(MouseEvent.MOUSE_OVER,over);
		}
		private function over(e:MouseEvent):void
		{
			removeAllPopupMenu();
			if(!MainSystem.getInstance().isBusy)
			{
				popupMenu=new PopupMenu(e.currentTarget,e.currentTarget.id)
				e.currentTarget.parent.addChild(popupMenu);
			}
		}
		private function removeAllPopupMenu():void
		{
			if(popupMenu!=null)
			{
				if(popupMenu.parent!=null)
				{
					popupMenu.parent.removeChild(popupMenu);
				}
				popupMenu.dispose();
				popupMenu=null;
			}
		}
	}
}